<template>
  <div class="statisticalanalysis">
    <el-button @click="print" class="signs print" v-if="list.shStatus == 2"
      >打印</el-button
    >
    <el-tooltip
      class="item"
      effect="dark"
      content="审核通过才可以打印"
      v-else
      placement="top-start"
    >
      <el-button class="signs print" style="cursor: not-allowed"
        >打印</el-button
      >
    </el-tooltip>
    <div ref="print">
      <el-card class="box-card">
        <!-- <table  border="1" cellspacing="0" width="80%" >
          <tr height="45px">
            <th colspan="8">临时用电安全作业证</th>
          </tr> -->
        <div style="width: 100%; text-align: center">
          <span
            style="
              height: 45px;
              display: inline-block;
              line-height: 45px;
              font-weight: 700;
            "
            >临时用电作业证</span
          >
        </div>
        <table border="1" cellspacing="0">
          <tr align="center" height="35px">
            <td width="16%">申请单位</td>
            <td width="16%">{{ list.sqdwmc }}</td>
            <td>申请人</td>
            <td width="16%">{{ list.sqrmc }}</td>
            <td width="16%">作业证编号</td>
            <td width="16%" colspan="2">{{ list.zyzbh }}</td>
          </tr>
          <tr align="center" height="35px">
            <td colspan="1">作业时间</td>
            <td colspan="5" align="center" style="padding-right: 4rem">
              自<span>{{ list.zykssj }}</span> 始<span>{{ list.zyjssj }}</span
              >止
            </td>
          </tr>
          <tr align="center" height="35px">
            <td colspan="1">作业地点</td>
            <td colspan="5">{{ list.zydd }}</td>
          </tr>
          <tr align="center" height="35px">
            <td>电源接入点</td>
            <td>{{ list.dyjrd }}</td>
            <td colspan="2">工作电压</td>
            <td colspan="2">{{ list.gzdy }}</td>
          </tr>
          <tr align="center" height="35px">
            <td colspan="1">用电设备及功率</td>
            <td colspan="5">{{ list.ydsbjgl }}</td>
          </tr>
          <tr align="center" height="35px">
            <td>作业人</td>
            <td>{{ list.zyrmc }}</td>
            <td colspan="2">电工证号</td>
            <td colspan="2">{{ list.dgzh }}</td>
          </tr>
          <tr align="center" height="80px">
            <td colspan="1">危害辨识</td>
            <td colspan="5">{{ list.whbs }}</td>
          </tr>
          <!-- 安全措施 -->
          <tr align="center" height="35px">
            <td>序号</td>
            <td colspan="4">安全措施</td>
            <td>确认人</td>
          </tr>
          <tr align="center" height="40px">
            <td>1</td>
            <td class="textleft" colspan="4">
              安装临时线路人员持有电工作业操作证
            </td>
            <td>{{ list.aqcsqrrmc }}</td>
          </tr>
          <tr align="center" height="40px">
            <td>2</td>
            <td class="textleft" colspan="4">
              在防爆场所使用的临时电源、元器件和线路达到相应的防爆等级要求
            </td>
            <td>{{ list.aqcsqrrmc }}</td>
          </tr>
          <tr align="center" height="40px">
            <td>3</td>
            <td class="textleft" colspan="4">
              临时用电的单相和混用线路采用五线制
            </td>
            <td>{{ list.aqcsqrrmc }}</td>
          </tr>
          <tr align="center" height="40px">
            <td>4</td>
            <td class="textleft" colspan="4">
              临时用电线路架空高度在装置内不低于2.5m，道路不低于5m
            </td>
            <td>{{ list.aqcsqrrmc }}</td>
          </tr>
          <tr align="center" height="40px">
            <td>5</td>
            <td class="textleft" colspan="4">
              临时用电线路架空进线未采用裸线，未在树上或脚手架上架设
            </td>
            <td>{{ list.aqcsqrrmc }}</td>
          </tr>
          <tr align="center" height="40px">
            <td>6</td>
            <td class="textleft" colspan="4">
              暗管埋设及地下电缆线路设有“走向标志”和安全标志，电缆埋深大于0.7m
            </td>
            <td>{{ list.aqcsqrrmc }}</td>
          </tr>
          <tr align="center" height="40px">
            <td>7</td>
            <td class="textleft" colspan="4">
              现场临时用电配电盘、箱应有防雨措施
            </td>
            <td>{{ list.aqcsqrrmc }}</td>
          </tr>
          <tr align="center" height="40px">
            <td>8</td>
            <td class="textleft" colspan="4">
              临时用电设施安有漏电保护器，移动工具、手持工具“一机一闸一保护”
            </td>
            <td>{{ list.aqcsqrrmc }}</td>
          </tr>
          <tr align="center" height="40px">
            <td>9</td>
            <td class="textleft" colspan="4">
              用电设备、线路容量、负荷符合要求
            </td>
            <td>{{ list.aqcsqrrmc }}</td>
          </tr>
          <tr align="center" height="80px">
            <td>10</td>
            <td colspan="4">
              <div class="tdPostion">
                <p class="Safetymeasures">其他安全措施：{{ list.qtaqcs }}</p>
              </div>
              <div class="trPositon">
                <p class="makePeopleTwo">编制人：{{ list.qtaqcsbzrmc }}</p>
              </div>
            </td>
            <td>{{ list.qtaqcsqrrmc }}</td>
          </tr>
          <tr align="center" height="40px">
            <td>实施安全教育</td>
            <td>{{ list.ssaqjyrmc }}</td>
            <td colspan="2"></td>
            <td colspan="2"></td>
          </tr>
          <tr height="60px">
            <td colspan="6" style="border-bottom: none; padding-left: 10px">
              生产单位作业负责人意见：{{ list.zydwyj }}
            </td>
          </tr>
          <tr height="60px">
            <td
              align="right"
              colspan="6"
              style="border-top: none; padding-right: 2rem"
            >
              签字：{{ list.zydwqzmc }}
              <span style="padding-left: 1rem">{{ list.zydwqzsj }}</span>
            </td>
          </tr>
          <tr height="60px">
            <td colspan="6" style="border-bottom: none; padding-left: 10px">
              配送电单位意见：{{ list.psddwyj }}
            </td>
          </tr>
          <tr height="60px">
            <td
              align="right"
              colspan="6"
              style="border-top: none; padding-right: 2rem"
            >
              签字：{{ list.psddwqzmc }}
              <span style="padding-left: 1rem">{{ list.psddwqzsj }}</span>
            </td>
          </tr>
          <tr height="60px">
            <td colspan="6" style="border-bottom: none; padding-left: 10px">
              审核部门意见：{{ list.spbmyj }}
            </td>
          </tr>
          <tr height="60px">
            <td
              align="right"
              colspan="6"
              style="border-top: none; padding-right: 2rem"
            >
              签字：{{ list.spbmqzmc }}
              <span style="padding-left: 1rem">{{ list.spsj }}</span>
            </td>
          </tr>
          <tr height="60px">
            <td colspan="6" style="border-bottom: none; padding-left: 10px">
              完工验收：{{ list.wgysyj }}
            </td>
          </tr>
          <tr height="60px">
            <td
              align="right"
              colspan="6"
              style="border-top: none; padding-right: 2rem"
            >
              签字：{{ list.wgysqzmc }}
              <span style="padding-left: 1rem">{{ list.wgysqzsj }}</span>
            </td>
          </tr>
        </table>
      </el-card>
    </div>
  </div>
</template>

<script>
import printStyle from "./printStyle";

export default {
  name: "linshi",
  props: {
    list: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {};
  },
  created() {
    this.list.zykssj = this.formatDateH(this.list.zykssj);
    this.list.zyjssj = this.formatDateH(this.list.zyjssj);
    this.list.zydwqzsj = this.formatDateH(this.list.zydwqzsj);
    this.list.psddwqzsj = this.formatDateH(this.list.psddwqzsj);
    this.list.spsj = this.formatDateH(this.list.spsj);
    this.list.wgysqzsj = this.formatDateH(this.list.wgysqzsj);
  },
  methods: {
    formatDate(needTime) {
      //needTime是整数，否则要parseInt转换
      if (needTime !== null && needTime !== undefined) {
        var time = new Date(needTime);
        var y = time.getFullYear();
        var m = time.getMonth() + 1;
        var d = time.getDate();
        var h = time.getHours();
        var mm = time.getMinutes();
        return y + "年" + this.add0(m) + "月" + this.add0(d) + "日";
      } else {
        return "  年  月  日";
      }
    },
    formatDateH(needTime) {
      //needTime是整数，否则要parseInt转换
      if (needTime !== null && needTime !== undefined) {
        var time = new Date(needTime);
        var y = time.getFullYear();
        var m = time.getMonth() + 1;
        var d = time.getDate();
        var h = time.getHours();
        var mm = time.getMinutes();
        // var s = time.getSeconds();
        return (
          y +
          "年" +
          this.add0(m) +
          "月" +
          this.add0(d) +
          "日" +
          this.add0(h) +
          "时" +
          this.add0(mm) +
          "分"
        );
      } else {
        return "  年  月  日  时  分";
      }
    },
    add0(m) {
      return m < 10 ? "0" + m : m;
    },
    // 打印
    print() {
      let print = this.$refs.print.innerHTML;
      let printPart = print + printStyle;
      let newTab = window.open("_blank");
      newTab.document.body.innerHTML = printPart;
      newTab.print();
      newTab.close();
    },
  },
};
</script>

<style lang="scss" scoped>
.statisticalanalysis {
  .signs {
    position: absolute;
    right: 10px;
    top: 70px;
    &.print {
      top: 20px;
      right: 50px;
    }
  }
  .box-card {
    width: 80%;
    margin: 0 auto;
    background: #fff;
    color: #606266;
    position: relative;
    table {
      margin: 0 auto;
      tr {
        .textleft {
          text-align: left;
          padding-left: 20px;
        }
      }
      span {
        display: inline-block;
        min-width: 20px;
      }
      // 其他安全措施
      tr:nth-child(18) {
        .trPositon {
          position: relative;
          height: 90px;
          width: 100%;
          .makePeopleTwo {
            position: absolute;
            right: 15%;
            top: 60%;
          }
        }
        .tdPostion {
          position: relative;
          width: 100%;
          height: 30px;
          .Safetymeasures {
            position: absolute;
            left: 2%;
            top: 50%;
          }
        }
      }
    }
  }
}
</style>